/**
 * 获取WX配置
 */
export function getWxSetting(): Promise<WechatMiniprogram.GetSettingSuccessCallbackResult> {
    return new Promise((resolve, reject) => {
        wx.getSetting({
            success: resolve,
            fail: reject
        })
    })
}

/**
 * 获取WX用户信息(返回匿名的用户信息)
 */
export function getWxUserInfo(): Promise<WechatMiniprogram.GetUserInfoSuccessCallbackResult> {
    return new Promise((resolve, reject) => {
        wx.getUserInfo({
            success: resolve,
            fail: reject
        })
    })
}

/**
 * 获取WX用户信息
 */
export function getWxUserProfile(): Promise<WechatMiniprogram.GetUserProfileSuccessCallbackResult> {
    return new Promise((resolve, reject) => {
        wx.getUserProfile({
            desc: '获取你的昵称、头像、地区及性别',
            success: resolve,
            fail: reject,
            lang: 'zh_CN'
        })
    })
}

/**
 * WX登录
 */
export function wxLogin(): Promise<WechatMiniprogram.LoginSuccessCallbackResult> {
    return new Promise((resolve, reject) => {
        wx.login({
            success: resolve,
            fail: reject
        })
    })
}
